.class public final Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;
.super Ljava/lang/Object;
.source "VideoCache.java"

# interfaces
.implements Lcom/burstly/lib/cache/ICache;
.implements Lcom/burstly/lib/service/ServerConfigurationService$IServerConfigurable;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$SDCardListener;,
        Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$VideoFetchTask;,
        Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;,
        Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;
    }
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "Ljava/lang/Object;",
        "Lcom/burstly/lib/cache/ICache",
        "<",
        "Ljava/lang/String;",
        ">;",
        "Lcom/burstly/lib/service/ServerConfigurationService$IServerConfigurable;"
    }
.end annotation


# static fields
.field private static final BURSTLY_VIDEO_CACHE_DIR_NAME:Ljava/lang/String; = "burstlyVideoCache"

.field private static final CACHE_SIZE:Ljava/util/concurrent/atomic/AtomicInteger; = null

.field private static final CACHE_TIME:Lcom/burstly/lib/component/networkcomponent/burstly/DayBasedCacheTimer; = null

.field private static final DEFAULT_CACHE_SIZE_LIMIT:I = 0x3200000

.field private static final DEFAULT_TIME_TO_LIVE:J = 0x3612c6000L

.field private static final FILE_COMPARATOR:Ljava/util/Comparator; = null
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Comparator",
            "<",
            "Ljava/io/File;",
            ">;"
        }
    .end annotation
.end field

.field private static final LOADING_FILES:Ljava/util/Set; = null
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Set",
            "<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private static final LOG:Lcom/burstly/lib/util/LoggerExt; = null

.field private static final TAG:Ljava/lang/String; = "VideoCache"

.field private static final VIDEO_CACHE_SIZE:Ljava/lang/String; = "videocachesize"

.field private static final VIDEO_CACHE_TTL:Ljava/lang/String; = "videocachettl"

.field private static final WRITE_CHUNK:I = 0xc800

.field static volatile sCacheDir:Ljava/io/File;

.field private static sInstance:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;


# instance fields
.field private mCacheListener:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;


# direct methods
.method static constructor <clinit>()V
    .locals 3

    .prologue
    .line 164
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    .line 194
    new-instance v0, Lcom/burstly/lib/component/networkcomponent/burstly/DayBasedCacheTimer;

    const-wide v1, 0x3612c6000L

    invoke-static {v1, v2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v1

    invoke-direct {v0, v1}, Lcom/burstly/lib/component/networkcomponent/burstly/DayBasedCacheTimer;-><init>(Ljava/lang/Long;)V

    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->CACHE_TIME:Lcom/burstly/lib/component/networkcomponent/burstly/DayBasedCacheTimer;

    .line 199
    new-instance v0, Ljava/util/concurrent/atomic/AtomicInteger;

    const/high16 v1, 0x320

    invoke-direct {v0, v1}, Ljava/util/concurrent/atomic/AtomicInteger;-><init>(I)V

    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->CACHE_SIZE:Ljava/util/concurrent/atomic/AtomicInteger;

    .line 204
    new-instance v0, Ljava/util/HashSet;

    invoke-direct {v0}, Ljava/util/HashSet;-><init>()V

    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOADING_FILES:Ljava/util/Set;

    .line 219
    new-instance v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$1;

    invoke-direct {v0}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$1;-><init>()V

    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->FILE_COMPARATOR:Ljava/util/Comparator;

    return-void
.end method

.method private constructor <init>(Landroid/content/Context;)V
    .locals 3
    .parameter "context"

    .prologue
    .line 254
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 255
    invoke-static {p0}, Lcom/burstly/lib/service/ServerConfigurationService;->addRecipient(Lcom/burstly/lib/service/ServerConfigurationService$IServerConfigurable;)V

    .line 256
    invoke-static {}, Lcom/burstly/lib/util/Utils;->canWriteToSDCard()Z

    move-result v1

    .line 257
    .local v1, testedResult:Z
    invoke-virtual {p1}, Landroid/content/Context;->getApplicationContext()Landroid/content/Context;

    move-result-object v0

    .line 258
    .local v0, applicationContext:Landroid/content/Context;
    invoke-static {v1, v0}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->initCacheDir(ZLandroid/content/Context;)V

    .line 260
    new-instance v2, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$SDCardListener;

    invoke-direct {v2, v0}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$SDCardListener;-><init>(Landroid/content/Context;)V

    invoke-static {v2}, Lcom/burstly/lib/service/SdCardWatchingService;->addNotificationListener(Lcom/burstly/lib/service/SdCardWatchingService$IWatcherNotificator;)V

    .line 261
    invoke-static {p0}, Lcom/burstly/lib/cache/CacheManager;->registerCache(Lcom/burstly/lib/cache/ICache;)V

    .line 262
    return-void
.end method

.method static synthetic access$000()Ljava/util/Set;
    .locals 1

    .prologue
    .line 63
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOADING_FILES:Ljava/util/Set;

    return-object v0
.end method

.method private static checkFileExistsAndActual(Ljava/io/File;)Z
    .locals 10
    .parameter "file"

    .prologue
    const/4 v3, 0x1

    const/4 v4, 0x0

    .line 718
    invoke-virtual {p0}, Ljava/io/File;->lastModified()J

    move-result-wide v0

    .line 719
    .local v0, creationDate:J
    invoke-virtual {p0}, Ljava/io/File;->exists()Z

    move-result v2

    .line 720
    .local v2, exists:Z
    if-eqz v2, :cond_1

    .line 721
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v5

    sget-object v7, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->CACHE_TIME:Lcom/burstly/lib/component/networkcomponent/burstly/DayBasedCacheTimer;

    invoke-virtual {v7}, Lcom/burstly/lib/component/networkcomponent/burstly/DayBasedCacheTimer;->get()J

    move-result-wide v7

    add-long/2addr v7, v0

    cmp-long v5, v5, v7

    if-gez v5, :cond_0

    .line 728
    :goto_0
    return v3

    .line 724
    :cond_0
    const-wide/16 v5, 0x0

    cmp-long v5, v0, v5

    if-eqz v5, :cond_1

    invoke-virtual {p0}, Ljava/io/File;->delete()Z

    move-result v5

    if-nez v5, :cond_1

    .line 725
    sget-object v5, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v6, "VideoCache"

    const-string v7, "Could not delete state video file  \'\'{0}\'\'. Temp directory is {1}"

    const/4 v8, 0x2

    new-array v8, v8, [Ljava/lang/Object;

    aput-object p0, v8, v4

    sget-object v9, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    aput-object v9, v8, v3

    invoke-virtual {v5, v6, v7, v8}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    :cond_1
    move v3, v4

    .line 728
    goto :goto_0
.end method

.method private static checkInterrupted()V
    .locals 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/InterruptedException;
        }
    .end annotation

    .prologue
    .line 706
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    if-nez v0, :cond_0

    .line 707
    new-instance v0, Ljava/lang/InterruptedException;

    const-string v1, "Video downloading thread interrupted."

    invoke-direct {v0, v1}, Ljava/lang/InterruptedException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 709
    :cond_0
    return-void
.end method

.method private static createCacheDirectoryIfNeed()V
    .locals 1

    .prologue
    .line 406
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    if-eqz v0, :cond_0

    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v0

    if-nez v0, :cond_0

    .line 407
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    invoke-virtual {v0}, Ljava/io/File;->mkdirs()Z

    .line 409
    :cond_0
    return-void
.end method

.method private static dirSize(Ljava/io/File;)J
    .locals 8
    .parameter "dir"

    .prologue
    .line 682
    const-wide/16 v2, 0x0

    .line 683
    .local v2, result:J
    if-nez p0, :cond_0

    move-wide v4, v2

    .line 696
    .end local v2           #result:J
    .local v4, result:J
    :goto_0
    return-wide v4

    .line 686
    .end local v4           #result:J
    .restart local v2       #result:J
    :cond_0
    invoke-virtual {p0}, Ljava/io/File;->listFiles()[Ljava/io/File;

    move-result-object v0

    .line 687
    .local v0, fileList:[Ljava/io/File;
    const/4 v1, 0x0

    .local v1, i:I
    :goto_1
    array-length v6, v0

    if-ge v1, v6, :cond_2

    .line 689
    aget-object v6, v0, v1

    invoke-virtual {v6}, Ljava/io/File;->isDirectory()Z

    move-result v6

    if-eqz v6, :cond_1

    .line 690
    aget-object v6, v0, v1

    invoke-static {v6}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->dirSize(Ljava/io/File;)J

    move-result-wide v6

    add-long/2addr v2, v6

    .line 687
    :goto_2
    add-int/lit8 v1, v1, 0x1

    goto :goto_1

    .line 693
    :cond_1
    aget-object v6, v0, v1

    invoke-virtual {v6}, Ljava/io/File;->length()J

    move-result-wide v6

    add-long/2addr v2, v6

    goto :goto_2

    :cond_2
    move-wide v4, v2

    .line 696
    .end local v2           #result:J
    .restart local v4       #result:J
    goto :goto_0
.end method

.method private declared-synchronized downloadVideo(Ljava/lang/String;Ljava/io/File;)V
    .locals 18
    .parameter "url"
    .parameter "targetFile"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lorg/apache/http/client/ClientProtocolException;,
            Ljava/io/IOException;,
            Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;
        }
    .end annotation

    .prologue
    .line 479
    monitor-enter p0

    const/4 v7, 0x0

    .line 481
    .local v7, fos:Ljava/io/FileOutputStream;
    :try_start_0
    sget-object v12, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v13, "VideoCache"

    const-string v14, "Video {0} is loading from internet."

    const/4 v15, 0x1

    new-array v15, v15, [Ljava/lang/Object;

    const/16 v16, 0x0

    aput-object p1, v15, v16

    invoke-virtual {v12, v13, v14, v15}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 482
    invoke-direct/range {p0 .. p1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->notifyStart(Ljava/lang/String;)V

    .line 483
    invoke-static {}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->checkInterrupted()V

    .line 484
    invoke-static/range {p1 .. p1}, Lcom/burstly/lib/util/Utils;->makeGetRequest(Ljava/lang/String;)Lorg/apache/http/HttpResponse;

    move-result-object v10

    .line 485
    .local v10, response:Lorg/apache/http/HttpResponse;
    invoke-interface {v10}, Lorg/apache/http/HttpResponse;->getStatusLine()Lorg/apache/http/StatusLine;

    move-result-object v12

    invoke-interface {v12}, Lorg/apache/http/StatusLine;->getStatusCode()I

    move-result v11

    .line 486
    .local v11, statusCode:I
    invoke-interface {v10}, Lorg/apache/http/HttpResponse;->getEntity()Lorg/apache/http/HttpEntity;

    move-result-object v6

    .line 487
    .local v6, entity:Lorg/apache/http/HttpEntity;
    invoke-interface {v6}, Lorg/apache/http/HttpEntity;->getContentLength()J

    move-result-wide v3

    .line 488
    .local v3, contentLength:J
    const/16 v12, 0xc8

    if-eq v11, v12, :cond_0

    .line 489
    new-instance v12, Ljava/lang/InterruptedException;

    new-instance v13, Ljava/lang/StringBuilder;

    invoke-direct {v13}, Ljava/lang/StringBuilder;-><init>()V

    const-string v14, "Can not download video, response code is "

    invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v13

    invoke-static {v11}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v14

    invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v13

    invoke-virtual {v13}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v13

    invoke-direct {v12, v13}, Ljava/lang/InterruptedException;-><init>(Ljava/lang/String;)V

    throw v12
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
    .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0

    .line 516
    .end local v3           #contentLength:J
    .end local v6           #entity:Lorg/apache/http/HttpEntity;
    .end local v10           #response:Lorg/apache/http/HttpResponse;
    .end local v11           #statusCode:I
    :catch_0
    move-exception v5

    .line 517
    .local v5, e:Ljava/lang/InterruptedException;
    :try_start_1
    sget-object v12, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v13, "VideoCache"

    const-string v14, "{0}\n video url: {1}"

    const/4 v15, 0x2

    new-array v15, v15, [Ljava/lang/Object;

    const/16 v16, 0x0

    invoke-virtual {v5}, Ljava/lang/InterruptedException;->getMessage()Ljava/lang/String;

    move-result-object v17

    aput-object v17, v15, v16

    const/16 v16, 0x1

    aput-object p1, v15, v16

    invoke-virtual {v12, v13, v14, v15}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 518
    invoke-virtual/range {p2 .. p2}, Ljava/io/File;->delete()Z

    move-result v12

    if-nez v12, :cond_6

    .line 519
    sget-object v12, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v13, "VideoCache"

    const-string v14, "Could not delete incompleted video file {0}"

    const/4 v15, 0x1

    new-array v15, v15, [Ljava/lang/Object;

    const/16 v16, 0x0

    aput-object p2, v15, v16

    invoke-virtual {v12, v13, v14, v15}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 523
    :goto_0
    invoke-direct/range {p0 .. p1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->notifyFailed(Ljava/lang/String;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 526
    :try_start_2
    invoke-static {v7}, Lcom/burstly/lib/util/Utils;->closeStream(Ljava/io/Closeable;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1

    .line 528
    .end local v5           #e:Ljava/lang/InterruptedException;
    :goto_1
    monitor-exit p0

    return-void

    .line 491
    .restart local v3       #contentLength:J
    .restart local v6       #entity:Lorg/apache/http/HttpEntity;
    .restart local v10       #response:Lorg/apache/http/HttpResponse;
    .restart local v11       #statusCode:I
    :cond_0
    const-wide/16 v12, 0x0

    cmp-long v12, v3, v12

    if-nez v12, :cond_1

    .line 492
    :try_start_3
    new-instance v12, Ljava/lang/InterruptedException;

    const-string v13, "Size is 0: video will not be served."

    invoke-direct {v12, v13}, Ljava/lang/InterruptedException;-><init>(Ljava/lang/String;)V

    throw v12
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0
    .catch Ljava/lang/InterruptedException; {:try_start_3 .. :try_end_3} :catch_0

    .line 526
    .end local v3           #contentLength:J
    .end local v6           #entity:Lorg/apache/http/HttpEntity;
    .end local v10           #response:Lorg/apache/http/HttpResponse;
    .end local v11           #statusCode:I
    :catchall_0
    move-exception v12

    :try_start_4
    invoke-static {v7}, Lcom/burstly/lib/util/Utils;->closeStream(Ljava/io/Closeable;)V

    throw v12
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1

    .line 479
    :catchall_1
    move-exception v12

    monitor-exit p0

    throw v12

    .line 494
    .restart local v3       #contentLength:J
    .restart local v6       #entity:Lorg/apache/http/HttpEntity;
    .restart local v10       #response:Lorg/apache/http/HttpResponse;
    .restart local v11       #statusCode:I
    :cond_1
    :try_start_5
    sget-object v12, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v13, "VideoCache"

    const-string v14, "{0} size: {1} bytes."

    const/4 v15, 0x2

    new-array v15, v15, [Ljava/lang/Object;

    const/16 v16, 0x0

    aput-object p1, v15, v16

    const/16 v16, 0x1

    invoke-static {v3, v4}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v17

    aput-object v17, v15, v16

    invoke-virtual {v12, v13, v14, v15}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 495
    invoke-static {v6, v3, v4}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->prepareSpace(Lorg/apache/http/HttpEntity;J)V

    .line 496
    new-instance v1, Ljava/io/ByteArrayOutputStream;

    const v12, 0xc800

    invoke-direct {v1, v12}, Ljava/io/ByteArrayOutputStream;-><init>(I)V

    .line 498
    .local v1, baos:Ljava/io/ByteArrayOutputStream;
    invoke-interface {v6}, Lorg/apache/http/HttpEntity;->getContent()Ljava/io/InputStream;

    move-result-object v8

    .line 499
    .local v8, in:Ljava/io/InputStream;
    const/16 v12, 0x2800

    new-array v2, v12, [B

    .line 500
    .local v2, buffer:[B
    const/4 v9, 0x0

    .line 501
    .local v9, len:I
    :cond_2
    :goto_2
    invoke-virtual {v8, v2}, Ljava/io/InputStream;->read([B)I

    move-result v9

    if-lez v9, :cond_3

    .line 502
    invoke-static {}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->checkInterrupted()V

    .line 503
    const/4 v12, 0x0

    invoke-virtual {v1, v2, v12, v9}, Ljava/io/ByteArrayOutputStream;->write([BII)V

    .line 504
    invoke-virtual {v1}, Ljava/io/ByteArrayOutputStream;->size()I

    move-result v12

    const v13, 0xc800

    if-lt v12, v13, :cond_2

    .line 505
    move-object/from16 v0, p2

    invoke-static {v0, v1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->writeToSd(Ljava/io/File;Ljava/io/ByteArrayOutputStream;)V

    goto :goto_2

    .line 508
    :cond_3
    invoke-virtual {v1}, Ljava/io/ByteArrayOutputStream;->size()I

    move-result v12

    if-eqz v12, :cond_4

    .line 509
    move-object/from16 v0, p2

    invoke-static {v0, v1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->writeToSd(Ljava/io/File;Ljava/io/ByteArrayOutputStream;)V

    .line 511
    :cond_4
    invoke-virtual/range {p2 .. p2}, Ljava/io/File;->length()J

    move-result-wide v12

    cmp-long v12, v12, v3

    if-eqz v12, :cond_5

    .line 512
    new-instance v12, Ljava/lang/InterruptedException;

    new-instance v13, Ljava/lang/StringBuilder;

    invoke-direct {v13}, Ljava/lang/StringBuilder;-><init>()V

    const-string v14, "Downloaded filesize is incorrect! Source file size:"

    invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v13

    invoke-virtual {v13, v3, v4}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v13

    const-string v14, ", downloaded file size: "

    invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v13

    invoke-virtual/range {p2 .. p2}, Ljava/io/File;->length()J

    move-result-wide v14

    invoke-virtual {v13, v14, v15}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v13

    invoke-virtual {v13}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v13

    invoke-direct {v12, v13}, Ljava/lang/InterruptedException;-><init>(Ljava/lang/String;)V

    throw v12
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0
    .catch Ljava/lang/InterruptedException; {:try_start_5 .. :try_end_5} :catch_0

    .line 526
    :cond_5
    :try_start_6
    invoke-static {v7}, Lcom/burstly/lib/util/Utils;->closeStream(Ljava/io/Closeable;)V
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_1

    goto/16 :goto_1

    .line 521
    .end local v1           #baos:Ljava/io/ByteArrayOutputStream;
    .end local v2           #buffer:[B
    .end local v3           #contentLength:J
    .end local v6           #entity:Lorg/apache/http/HttpEntity;
    .end local v8           #in:Ljava/io/InputStream;
    .end local v9           #len:I
    .end local v10           #response:Lorg/apache/http/HttpResponse;
    .end local v11           #statusCode:I
    .restart local v5       #e:Ljava/lang/InterruptedException;
    :cond_6
    :try_start_7
    sget-object v12, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v13, "VideoCache"

    const-string v14, "Deleted incomplete video file {0}"

    const/4 v15, 0x1

    new-array v15, v15, [Ljava/lang/Object;

    const/16 v16, 0x0

    aput-object p2, v15, v16

    invoke-virtual {v12, v13, v14, v15}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    :try_end_7
    .catchall {:try_start_7 .. :try_end_7} :catchall_0

    goto/16 :goto_0
.end method

.method private static freeUpSpaceIfNeed(J)V
    .locals 18
    .parameter "bytesToWrite"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;,
            Ljava/lang/InterruptedException;
        }
    .end annotation

    .prologue
    .line 638
    sget-object v11, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->CACHE_SIZE:Ljava/util/concurrent/atomic/AtomicInteger;

    invoke-virtual {v11}, Ljava/util/concurrent/atomic/AtomicInteger;->get()I

    move-result v0

    .line 639
    .local v0, currentCacheSize:I
    int-to-long v11, v0

    cmp-long v11, p0, v11

    if-lez v11, :cond_0

    .line 640
    new-instance v11, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;

    const-string v12, "File is too big to fit cache limit"

    const/4 v13, 0x0

    invoke-direct {v11, v12, v13}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;-><init>(Ljava/lang/String;Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$1;)V

    throw v11

    .line 642
    :cond_0
    sget-object v11, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    invoke-static {v11}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->dirSize(Ljava/io/File;)J

    move-result-wide v8

    .line 643
    .local v8, totalCacheSize:J
    add-long v11, v8, p0

    int-to-long v13, v0

    sub-long v6, v11, v13

    .line 644
    .local v6, toFree:J
    const-wide/16 v11, 0x0

    cmp-long v11, v6, v11

    if-lez v11, :cond_2

    .line 645
    invoke-static {}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->checkInterrupted()V

    .line 646
    sget-object v11, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    new-instance v12, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$3;

    invoke-direct {v12}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$3;-><init>()V

    invoke-virtual {v11, v12}, Ljava/io/File;->listFiles(Ljava/io/FilenameFilter;)[Ljava/io/File;

    move-result-object v10

    .line 653
    .local v10, writtenFiles:[Ljava/io/File;
    invoke-static {v10}, Ljava/util/Arrays;->asList([Ljava/lang/Object;)Ljava/util/List;

    move-result-object v2

    .line 654
    .local v2, fileList:Ljava/util/List;,"Ljava/util/List<Ljava/io/File;>;"
    sget-object v11, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->FILE_COMPARATOR:Ljava/util/Comparator;

    invoke-static {v2, v11}, Ljava/util/Collections;->sort(Ljava/util/List;Ljava/util/Comparator;)V

    .line 655
    const-wide/16 v4, 0x0

    .line 656
    .local v4, releasedBytes:J
    sget-object v11, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v12, "VideoCache"

    const-string v13, "Cleaning up oldest cached video to free up space to cache new file..."

    const/4 v14, 0x0

    new-array v14, v14, [Ljava/lang/Object;

    invoke-virtual {v11, v12, v13, v14}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 657
    invoke-interface {v2}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v3

    .local v3, i$:Ljava/util/Iterator;
    :cond_1
    invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z

    move-result v11

    if-eqz v11, :cond_2

    invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Ljava/io/File;

    .line 658
    .local v1, file:Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->isFile()Z

    move-result v11

    if-eqz v11, :cond_1

    .line 659
    invoke-virtual {v1}, Ljava/io/File;->length()J

    move-result-wide v11

    add-long/2addr v4, v11

    .line 660
    sget-object v11, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v12, "VideoCache"

    const-string v13, "File: {0}, size {1}"

    const/4 v14, 0x2

    new-array v14, v14, [Ljava/lang/Object;

    const/4 v15, 0x0

    invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v16

    aput-object v16, v14, v15

    const/4 v15, 0x1

    invoke-virtual {v1}, Ljava/io/File;->length()J

    move-result-wide v16

    invoke-static/range {v16 .. v17}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v16

    aput-object v16, v14, v15

    invoke-virtual {v11, v12, v13, v14}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 661
    sget-object v11, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v12, "VideoCache"

    const-string v13, "Fred up {0}, need to free: {1}"

    const/4 v14, 0x2

    new-array v14, v14, [Ljava/lang/Object;

    const/4 v15, 0x0

    invoke-static {v4, v5}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v16

    aput-object v16, v14, v15

    const/4 v15, 0x1

    invoke-static {v6, v7}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v16

    aput-object v16, v14, v15

    invoke-virtual {v11, v12, v13, v14}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 662
    invoke-virtual {v1}, Ljava/io/File;->delete()Z

    move-result v11

    if-nez v11, :cond_3

    .line 663
    sget-object v11, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v12, "VideoCache"

    const-string v13, "Could not delete cached video file {0}"

    const/4 v14, 0x1

    new-array v14, v14, [Ljava/lang/Object;

    const/4 v15, 0x0

    aput-object v1, v14, v15

    invoke-virtual {v11, v12, v13, v14}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 667
    :goto_0
    cmp-long v11, v4, v6

    if-ltz v11, :cond_1

    .line 673
    .end local v1           #file:Ljava/io/File;
    .end local v2           #fileList:Ljava/util/List;,"Ljava/util/List<Ljava/io/File;>;"
    .end local v3           #i$:Ljava/util/Iterator;
    .end local v4           #releasedBytes:J
    .end local v10           #writtenFiles:[Ljava/io/File;
    :cond_2
    return-void

    .line 665
    .restart local v1       #file:Ljava/io/File;
    .restart local v2       #fileList:Ljava/util/List;,"Ljava/util/List<Ljava/io/File;>;"
    .restart local v3       #i$:Ljava/util/Iterator;
    .restart local v4       #releasedBytes:J
    .restart local v10       #writtenFiles:[Ljava/io/File;
    :cond_3
    sget-object v11, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v12, "VideoCache"

    const-string v13, "Deleted cached video file {0}"

    const/4 v14, 0x1

    new-array v14, v14, [Ljava/lang/Object;

    const/4 v15, 0x0

    aput-object v1, v14, v15

    invoke-virtual {v11, v12, v13, v14}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    goto :goto_0
.end method

.method public static getInstance()Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;
    .locals 4

    .prologue
    .line 748
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sInstance:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;

    if-nez v0, :cond_0

    .line 749
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "VideoCache"

    const-string v2, "Video cache is not initialized! Call VideoCache.initCache first!"

    const/4 v3, 0x0

    new-array v3, v3, [Ljava/lang/Object;

    invoke-virtual {v0, v1, v2, v3}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 751
    :cond_0
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sInstance:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;

    return-object v0
.end method

.method public static getInstance(Landroid/content/Context;)Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;
    .locals 4
    .parameter "currentContext"

    .prologue
    .line 761
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sInstance:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;

    if-nez v0, :cond_0

    .line 762
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "VideoCache"

    const-string v2, "Video cache is not initialized. Initializing..."

    const/4 v3, 0x0

    new-array v3, v3, [Ljava/lang/Object;

    invoke-virtual {v0, v1, v2, v3}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 763
    invoke-static {p0}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->initCache(Landroid/content/Context;)V

    .line 765
    :cond_0
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sInstance:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;

    return-object v0
.end method

.method private static hasEnoghSpaceOnSd(Lorg/apache/http/HttpEntity;)V
    .locals 10
    .parameter "entity"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;
        }
    .end annotation

    .prologue
    const-wide/16 v8, 0x400

    .line 606
    new-instance v3, Landroid/os/StatFs;

    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v4

    invoke-virtual {v4}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v4

    invoke-direct {v3, v4}, Landroid/os/StatFs;-><init>(Ljava/lang/String;)V

    .line 607
    .local v3, stat:Landroid/os/StatFs;
    invoke-virtual {v3}, Landroid/os/StatFs;->getBlockSize()I

    move-result v4

    int-to-long v4, v4

    invoke-virtual {v3}, Landroid/os/StatFs;->getBlockCount()I

    move-result v6

    int-to-long v6, v6

    mul-long v0, v4, v6

    .line 608
    .local v0, bytesAvailable:J
    invoke-interface {p0}, Lorg/apache/http/HttpEntity;->getContentLength()J

    move-result-wide v4

    cmp-long v4, v4, v0

    if-lez v4, :cond_0

    .line 609
    new-instance v2, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    const-string v5, "Not enough space on sd card to precache video file. File size: "

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-interface {p0}, Lorg/apache/http/HttpEntity;->getContentLength()J

    move-result-wide v5

    div-long/2addr v5, v8

    invoke-virtual {v4, v5, v6}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v4

    const-string v5, " KB, available: "

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    div-long v5, v0, v8

    invoke-virtual {v4, v5, v6}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    move-result-object v4

    const-string v5, " KB."

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    const/4 v5, 0x0

    invoke-direct {v2, v4, v5}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;-><init>(Ljava/lang/String;Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$1;)V

    .line 612
    .local v2, ise:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;
    throw v2

    .line 614
    .end local v2           #ise:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;
    :cond_0
    return-void
.end method

.method static declared-synchronized initCache(Landroid/content/Context;)V
    .locals 2
    .parameter "ctxt"

    .prologue
    .line 737
    const-class v1, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;

    monitor-enter v1

    :try_start_0
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sInstance:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;

    if-nez v0, :cond_0

    .line 738
    new-instance v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;

    invoke-direct {v0, p0}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;-><init>(Landroid/content/Context;)V

    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sInstance:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 740
    :cond_0
    monitor-exit v1

    return-void

    .line 737
    :catchall_0
    move-exception v0

    monitor-exit v1

    throw v0
.end method

.method static initCacheDir(ZLandroid/content/Context;)V
    .locals 6
    .parameter "isUsable"
    .parameter "context"

    .prologue
    const/4 v5, 0x0

    .line 316
    if-eqz p1, :cond_0

    .line 318
    if-eqz p0, :cond_1

    .line 319
    new-instance v0, Ljava/io/File;

    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v1

    const-string v2, "burstlyVideoCache"

    invoke-direct {v0, v1, v2}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    .line 320
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "VideoCache"

    const-string v2, "Video cache directory is : {0}"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Object;

    sget-object v4, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    aput-object v4, v3, v5

    invoke-virtual {v0, v1, v2, v3}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 325
    :goto_0
    invoke-static {}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->createCacheDirectoryIfNeed()V

    .line 326
    invoke-static {}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->removeChunks()V

    .line 328
    :cond_0
    return-void

    .line 322
    :cond_1
    const/4 v0, 0x0

    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    .line 323
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "VideoCache"

    const-string v2, "SD card is unavalable, video precache is disabled."

    new-array v3, v5, [Ljava/lang/Object;

    invoke-virtual {v0, v1, v2, v3}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    goto :goto_0
.end method

.method private notifyEnd(Ljava/lang/String;)V
    .locals 5
    .parameter "url"

    .prologue
    .line 548
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "VideoCache"

    const-string v2, "End downloading notification: {0}"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    aput-object p1, v3, v4

    invoke-virtual {v0, v1, v2, v3}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 549
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->mCacheListener:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;

    if-eqz v0, :cond_0

    .line 550
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->mCacheListener:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;

    invoke-interface {v0, p1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;->downloadFinished(Ljava/lang/String;)V

    .line 552
    :cond_0
    return-void
.end method

.method private notifyFailed(Ljava/lang/String;)V
    .locals 5
    .parameter "url"

    .prologue
    .line 560
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "VideoCache"

    const-string v2, "Failed downloading notification: {0}"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    aput-object p1, v3, v4

    invoke-virtual {v0, v1, v2, v3}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 561
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->mCacheListener:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;

    if-eqz v0, :cond_0

    .line 562
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->mCacheListener:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;

    invoke-interface {v0, p1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;->downloadFailed(Ljava/lang/String;)V

    .line 564
    :cond_0
    return-void
.end method

.method private notifyStart(Ljava/lang/String;)V
    .locals 5
    .parameter "url"

    .prologue
    .line 536
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v1, "VideoCache"

    const-string v2, "Start downloading notification: {0}"

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    aput-object p1, v3, v4

    invoke-virtual {v0, v1, v2, v3}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 537
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->mCacheListener:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;

    if-eqz v0, :cond_0

    .line 538
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->mCacheListener:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;

    invoke-interface {v0, p1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;->downloadStarted(Ljava/lang/String;)V

    .line 540
    :cond_0
    return-void
.end method

.method private static prepareSpace(Lorg/apache/http/HttpEntity;J)V
    .locals 0
    .parameter "entity"
    .parameter "contentLength"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;,
            Ljava/lang/InterruptedException;
        }
    .end annotation

    .prologue
    .line 576
    invoke-static {}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->checkInterrupted()V

    .line 577
    invoke-static {p1, p2}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->freeUpSpaceIfNeed(J)V

    .line 578
    invoke-static {p0}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->hasEnoghSpaceOnSd(Lorg/apache/http/HttpEntity;)V

    .line 579
    return-void
.end method

.method private static declared-synchronized removeChunks()V
    .locals 11

    .prologue
    .line 344
    const-class v6, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;

    monitor-enter v6

    :try_start_0
    sget-object v5, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    if-eqz v5, :cond_1

    .line 345
    sget-object v5, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    new-instance v7, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$2;

    invoke-direct {v7}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$2;-><init>()V

    invoke-virtual {v5, v7}, Ljava/io/File;->listFiles(Ljava/io/FilenameFilter;)[Ljava/io/File;

    move-result-object v2

    .line 352
    .local v2, filesToDelete:[Ljava/io/File;
    if-eqz v2, :cond_1

    array-length v5, v2

    if-eqz v5, :cond_1

    .line 353
    move-object v0, v2

    .local v0, arr$:[Ljava/io/File;
    array-length v4, v0

    .local v4, len$:I
    const/4 v3, 0x0

    .local v3, i$:I
    :goto_0
    if-ge v3, v4, :cond_1

    aget-object v1, v0, v3

    .line 354
    .local v1, file:Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->isDirectory()Z

    move-result v5

    if-nez v5, :cond_0

    .line 355
    sget-object v5, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v7, "VideoCache"

    const-string v8, "Erasing corrupted video file  {0}"

    const/4 v9, 0x1

    new-array v9, v9, [Ljava/lang/Object;

    const/4 v10, 0x0

    aput-object v1, v9, v10

    invoke-virtual {v5, v7, v8, v9}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 356
    invoke-virtual {v1}, Ljava/io/File;->delete()Z

    move-result v5

    if-nez v5, :cond_0

    .line 357
    sget-object v5, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v7, "VideoCache"

    const-string v8, "Failed to erase corrupted video file  {0}"

    const/4 v9, 0x1

    new-array v9, v9, [Ljava/lang/Object;

    const/4 v10, 0x0

    aput-object v1, v9, v10

    invoke-virtual {v5, v7, v8, v9}, Lcom/burstly/lib/util/LoggerExt;->logError(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 353
    :cond_0
    add-int/lit8 v3, v3, 0x1

    goto :goto_0

    .line 363
    .end local v0           #arr$:[Ljava/io/File;
    .end local v1           #file:Ljava/io/File;
    .end local v3           #i$:I
    .end local v4           #len$:I
    :cond_1
    monitor-exit v6

    return-void

    .line 344
    :catchall_0
    move-exception v5

    monitor-exit v6

    throw v5
.end method

.method private static rename(Ljava/io/File;Ljava/lang/String;)Ljava/io/File;
    .locals 2
    .parameter "origFile"
    .parameter "newName"

    .prologue
    .line 624
    new-instance v0, Ljava/io/File;

    sget-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    invoke-direct {v0, v1, p1}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 625
    .local v0, dest:Ljava/io/File;
    invoke-virtual {p0, v0}, Ljava/io/File;->renameTo(Ljava/io/File;)Z

    .line 626
    return-object v0
.end method

.method private tryToSetNewCacheSize(Ljava/lang/String;)V
    .locals 6
    .parameter "newValue"

    .prologue
    const/4 v4, 0x1

    const/4 v5, 0x0

    .line 809
    const/4 v1, -0x1

    invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v1

    invoke-static {p1, v1}, Lcom/burstly/lib/util/Utils;->getIntValue(Ljava/lang/String;Ljava/lang/Integer;)Ljava/lang/Integer;

    move-result-object v0

    .line 810
    .local v0, newCacheValue:Ljava/lang/Integer;
    invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

    move-result v1

    if-ltz v1, :cond_0

    .line 811
    sget-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->CACHE_SIZE:Ljava/util/concurrent/atomic/AtomicInteger;

    invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

    move-result v2

    const/high16 v3, 0x10

    mul-int/2addr v2, v3

    invoke-virtual {v1, v2}, Ljava/util/concurrent/atomic/AtomicInteger;->set(I)V

    .line 812
    sget-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v2, "VideoCache"

    const-string v3, "New value for video cache size was set {0} MB."

    new-array v4, v4, [Ljava/lang/Object;

    aput-object v0, v4, v5

    invoke-virtual {v1, v2, v3, v4}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 816
    :goto_0
    return-void

    .line 814
    :cond_0
    sget-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v2, "VideoCache"

    const-string v3, "Invalid new value for video cache size {0}, ignoring."

    new-array v4, v4, [Ljava/lang/Object;

    aput-object p1, v4, v5

    invoke-virtual {v1, v2, v3, v4}, Lcom/burstly/lib/util/LoggerExt;->logWarning(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    goto :goto_0
.end method

.method private static writeToSd(Ljava/io/File;Ljava/io/ByteArrayOutputStream;)V
    .locals 2
    .parameter "targetFile"
    .parameter "baos"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/FileNotFoundException;,
            Ljava/io/IOException;,
            Ljava/lang/InterruptedException;
        }
    .end annotation

    .prologue
    .line 592
    invoke-static {}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->checkInterrupted()V

    .line 593
    new-instance v0, Ljava/io/FileOutputStream;

    const/4 v1, 0x1

    invoke-direct {v0, p0, v1}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;Z)V

    .line 594
    .local v0, fos:Ljava/io/FileOutputStream;
    invoke-virtual {p1}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/io/FileOutputStream;->write([B)V

    .line 595
    invoke-virtual {p1}, Ljava/io/ByteArrayOutputStream;->reset()V

    .line 596
    invoke-virtual {v0}, Ljava/io/FileOutputStream;->close()V

    .line 597
    return-void
.end method


# virtual methods
.method public cacheVideo(Ljava/lang/String;)V
    .locals 0
    .parameter "url"

    .prologue
    .line 306
    invoke-virtual {p0, p1, p1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->cacheVideo(Ljava/lang/String;Ljava/lang/String;)V

    .line 307
    return-void
.end method

.method public cacheVideo(Ljava/lang/String;Ljava/lang/String;)V
    .locals 2
    .parameter "url"
    .parameter "cacheKey"

    .prologue
    .line 296
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOADING_FILES:Ljava/util/Set;

    invoke-interface {v0, p1}, Ljava/util/Set;->add(Ljava/lang/Object;)Z

    .line 297
    new-instance v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$VideoFetchTask;

    const-string v1, "VideoCache"

    invoke-direct {v0, p0, p1, p2, v1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$VideoFetchTask;-><init>(Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    const/4 v1, 0x0

    new-array v1, v1, [Ljava/lang/Void;

    invoke-virtual {v0, v1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$VideoFetchTask;->execute([Ljava/lang/Object;)Landroid/os/AsyncTask;

    .line 298
    return-void
.end method

.method public configure(Ljava/util/Map;)V
    .locals 8
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Ljava/lang/Object;",
            ">;)V"
        }
    .end annotation

    .prologue
    .local p1, configurationData:Ljava/util/Map;,"Ljava/util/Map<Ljava/lang/String;Ljava/lang/Object;>;"
    const/high16 v7, 0x320

    const/4 v5, 0x1

    const/4 v6, 0x0

    .line 790
    sget-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v2, "VideoCache"

    const-string v3, "Confuiring VideoCache with params: {0}"

    new-array v4, v5, [Ljava/lang/Object;

    aput-object p1, v4, v6

    invoke-virtual {v1, v2, v3, v4}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 791
    const-string v1, "videocachettl"

    invoke-interface {p1, v1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/String;

    .line 792
    .local v0, newValue:Ljava/lang/String;
    sget-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->CACHE_TIME:Lcom/burstly/lib/component/networkcomponent/burstly/DayBasedCacheTimer;

    invoke-virtual {v1, v0}, Lcom/burstly/lib/component/networkcomponent/burstly/DayBasedCacheTimer;->setNewTTLValue(Ljava/lang/String;)V

    .line 793
    const-string v1, "videocachesize"

    invoke-interface {p1, v1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    .end local v0           #newValue:Ljava/lang/String;
    check-cast v0, Ljava/lang/String;

    .line 794
    .restart local v0       #newValue:Ljava/lang/String;
    if-eqz v0, :cond_0

    .line 795
    invoke-direct {p0, v0}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->tryToSetNewCacheSize(Ljava/lang/String;)V

    .line 801
    :goto_0
    return-void

    .line 797
    :cond_0
    sget-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v2, "VideoCache"

    const-string v3, "No value for cache in config from server, setting default value {0}bytes"

    new-array v4, v5, [Ljava/lang/Object;

    invoke-static {v7}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v5

    aput-object v5, v4, v6

    invoke-virtual {v1, v2, v3, v4}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 799
    sget-object v1, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->CACHE_SIZE:Ljava/util/concurrent/atomic/AtomicInteger;

    invoke-virtual {v1, v7}, Ljava/util/concurrent/atomic/AtomicInteger;->set(I)V

    goto :goto_0
.end method

.method public getCacheDir()Ljava/io/File;
    .locals 1

    .prologue
    .line 337
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    return-object v0
.end method

.method public getCacheListener()Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;
    .locals 1

    .prologue
    .line 778
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->mCacheListener:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;

    return-object v0
.end method

.method public bridge synthetic getResource(Ljava/lang/String;)Ljava/lang/Object;
    .locals 1
    .parameter "x0"

    .prologue
    .line 63
    invoke-virtual {p0, p1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->getResource(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getResource(Ljava/lang/String;)Ljava/lang/String;
    .locals 1
    .parameter "resourceId"

    .prologue
    const/4 v0, 0x0

    .line 770
    invoke-virtual {p0, p1, v0}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->getVideoPath(Ljava/lang/String;Ljava/lang/String;)V

    .line 771
    return-object v0
.end method

.method public getTtl()J
    .locals 2

    .prologue
    .line 825
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->CACHE_TIME:Lcom/burstly/lib/component/networkcomponent/burstly/DayBasedCacheTimer;

    invoke-virtual {v0}, Lcom/burstly/lib/component/networkcomponent/burstly/DayBasedCacheTimer;->get()J

    move-result-wide v0

    return-wide v0
.end method

.method getVideoPath(Ljava/lang/String;Ljava/lang/String;)V
    .locals 18
    .parameter "url"
    .parameter "cacheUrl"

    .prologue
    .line 419
    sget-object v9, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    if-nez v9, :cond_0

    .line 420
    sget-object v9, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v10, "VideoCache"

    const-string v11, "SD card is unavailable."

    const/4 v12, 0x0

    new-array v12, v12, [Ljava/lang/Object;

    invoke-virtual {v9, v10, v11, v12}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 421
    invoke-direct/range {p0 .. p1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->notifyFailed(Ljava/lang/String;)V

    .line 456
    :goto_0
    return-void

    .line 424
    :cond_0
    const/4 v6, 0x0

    .line 425
    .local v6, hasError:Z
    new-instance v9, Ljava/lang/StringBuilder;

    invoke-direct {v9}, Ljava/lang/StringBuilder;-><init>()V

    const-string v10, "_"

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual/range {p2 .. p2}, Ljava/lang/String;->hashCode()I

    move-result v10

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-static {v9}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    .line 426
    .local v5, filename:Ljava/lang/String;
    invoke-static {}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->createCacheDirectoryIfNeed()V

    .line 427
    new-instance v4, Ljava/io/File;

    sget-object v9, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    invoke-direct {v4, v9, v5}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 430
    .local v4, file:Ljava/io/File;
    :try_start_0
    sget-object v9, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v10, "VideoCache"

    const-string v11, "Waiting turn to load video {0}..."

    const/4 v12, 0x1

    new-array v12, v12, [Ljava/lang/Object;

    const/4 v13, 0x0

    aput-object p1, v12, v13

    invoke-virtual {v9, v10, v11, v12}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 431
    move-object/from16 v0, p0

    move-object/from16 v1, p1

    invoke-direct {v0, v1, v4}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->downloadVideo(Ljava/lang/String;Ljava/io/File;)V

    .line 432
    invoke-virtual {v4}, Ljava/io/File;->getName()Ljava/lang/String;

    move-result-object v9

    const/4 v10, 0x1

    invoke-virtual {v9, v10}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v9

    invoke-static {v4, v9}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->rename(Ljava/io/File;Ljava/lang/String;)Ljava/io/File;

    move-result-object v4

    .line 433
    sget-object v9, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v10, "VideoCache"

    const-string v11, "{0} {1}KB loaded."

    const/4 v12, 0x2

    new-array v12, v12, [Ljava/lang/Object;

    const/4 v13, 0x0

    aput-object p1, v12, v13

    const/4 v13, 0x1

    invoke-virtual {v4}, Ljava/io/File;->length()J

    move-result-wide v14

    const-wide/16 v16, 0x400

    div-long v14, v14, v16

    invoke-static {v14, v15}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v14

    aput-object v14, v12, v13

    invoke-virtual {v9, v10, v11, v12}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    :try_end_0
    .catch Ljava/net/SocketTimeoutException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException; {:try_start_0 .. :try_end_0} :catch_2
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_3

    .line 451
    :goto_1
    if-eqz v6, :cond_1

    .line 452
    invoke-direct/range {p0 .. p1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->notifyFailed(Ljava/lang/String;)V

    goto :goto_0

    .line 435
    :catch_0
    move-exception v8

    .line 436
    .local v8, ste:Ljava/net/SocketTimeoutException;
    sget-object v9, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v10, "VideoCache"

    const-string v11, "Could not read video data in specified {0} timeout!"

    const/4 v12, 0x1

    new-array v12, v12, [Ljava/lang/Object;

    const/4 v13, 0x0

    invoke-static {}, Lcom/burstly/lib/network/TimeoutManager;->getConnectTimeout()I

    move-result v14

    invoke-static {v14}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v14

    aput-object v14, v12, v13

    invoke-virtual {v9, v10, v11, v12}, Lcom/burstly/lib/util/LoggerExt;->logError(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 437
    const/4 v6, 0x1

    .line 450
    goto :goto_1

    .line 439
    .end local v8           #ste:Ljava/net/SocketTimeoutException;
    :catch_1
    move-exception v2

    .line 440
    .local v2, e:Ljava/io/IOException;
    sget-object v9, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v10, "VideoCache"

    const-string v11, "IO Exception.\n {0}"

    const/4 v12, 0x1

    new-array v12, v12, [Ljava/lang/Object;

    const/4 v13, 0x0

    invoke-static {v2}, Landroid/util/Log;->getStackTraceString(Ljava/lang/Throwable;)Ljava/lang/String;

    move-result-object v14

    aput-object v14, v12, v13

    invoke-virtual {v9, v10, v11, v12}, Lcom/burstly/lib/util/LoggerExt;->logError(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 441
    const/4 v6, 0x1

    .line 450
    goto :goto_1

    .line 443
    .end local v2           #e:Ljava/io/IOException;
    :catch_2
    move-exception v7

    .line 444
    .local v7, ise:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;
    sget-object v9, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v10, "VideoCache"

    const-string v11, "{0} {1}"

    const/4 v12, 0x2

    new-array v12, v12, [Ljava/lang/Object;

    const/4 v13, 0x0

    aput-object p1, v12, v13

    const/4 v13, 0x1

    invoke-virtual {v7}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;->getMessage()Ljava/lang/String;

    move-result-object v14

    aput-object v14, v12, v13

    invoke-virtual {v9, v10, v11, v12}, Lcom/burstly/lib/util/LoggerExt;->logError(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 445
    const/4 v6, 0x1

    .line 450
    goto :goto_1

    .line 447
    .end local v7           #ise:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$InsufficientSpaceException;
    :catch_3
    move-exception v3

    .line 448
    .local v3, ex:Ljava/lang/Exception;
    sget-object v9, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v10, "VideoCache"

    invoke-static {v3}, Landroid/util/Log;->getStackTraceString(Ljava/lang/Throwable;)Ljava/lang/String;

    move-result-object v11

    const/4 v12, 0x0

    new-array v12, v12, [Ljava/lang/Object;

    invoke-virtual {v9, v10, v11, v12}, Lcom/burstly/lib/util/LoggerExt;->logError(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 449
    const/4 v6, 0x1

    goto :goto_1

    .line 454
    .end local v3           #ex:Ljava/lang/Exception;
    :cond_1
    invoke-direct/range {p0 .. p1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->notifyEnd(Ljava/lang/String;)V

    goto/16 :goto_0
.end method

.method public hasFileInCache(Ljava/lang/String;)Ljava/lang/String;
    .locals 1
    .parameter "url"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalStateException;
        }
    .end annotation

    .prologue
    .line 399
    invoke-virtual {p0, p1, p1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->hasFileInCache(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public hasFileInCache(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 9
    .parameter "url"
    .parameter "cacheKey"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalStateException;
        }
    .end annotation

    .prologue
    const/4 v3, 0x0

    const/4 v7, 0x1

    const/4 v8, 0x0

    .line 374
    sget-object v4, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    if-nez v4, :cond_0

    .line 375
    sget-object v4, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v5, "VideoCache"

    const-string v6, "SD card is unavailable."

    new-array v7, v8, [Ljava/lang/Object;

    invoke-virtual {v4, v5, v6, v7}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 388
    :goto_0
    return-object v3

    .line 378
    :cond_0
    invoke-virtual {p2}, Ljava/lang/String;->hashCode()I

    move-result v4

    invoke-static {v4}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v2

    .line 379
    .local v2, filename:Ljava/lang/String;
    invoke-static {}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->createCacheDirectoryIfNeed()V

    .line 380
    new-instance v1, Ljava/io/File;

    sget-object v4, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    invoke-direct {v1, v4, v2}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 382
    .local v1, file:Ljava/io/File;
    invoke-static {v1}, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->checkFileExistsAndActual(Ljava/io/File;)Z

    move-result v0

    .line 383
    .local v0, exists:Z
    if-eqz v0, :cond_1

    sget-object v4, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOADING_FILES:Ljava/util/Set;

    invoke-interface {v4, p1}, Ljava/util/Set;->contains(Ljava/lang/Object;)Z

    move-result v4

    if-nez v4, :cond_1

    .line 384
    sget-object v3, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v4, "VideoCache"

    const-string v5, "Video {0} exists in file cache."

    new-array v6, v7, [Ljava/lang/Object;

    aput-object p1, v6, v8

    invoke-virtual {v3, v4, v5, v6}, Lcom/burstly/lib/util/LoggerExt;->logInfo(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    .line 385
    invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v3

    goto :goto_0

    .line 387
    :cond_1
    sget-object v4, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v5, "VideoCache"

    const-string v6, "No cached video file for {0} url."

    new-array v7, v7, [Ljava/lang/Object;

    aput-object p1, v7, v8

    invoke-virtual {v4, v5, v6, v7}, Lcom/burstly/lib/util/LoggerExt;->logDebug(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    goto :goto_0
.end method

.method public isConstantRecepient()Z
    .locals 1

    .prologue
    .line 820
    const/4 v0, 0x1

    return v0
.end method

.method public isLoadingNow(Ljava/lang/String;)Z
    .locals 1
    .parameter "url"

    .prologue
    .line 465
    sget-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->LOADING_FILES:Ljava/util/Set;

    invoke-interface {v0, p1}, Ljava/util/Set;->contains(Ljava/lang/Object;)Z

    move-result v0

    return v0
.end method

.method public release()V
    .locals 1

    .prologue
    const/4 v0, 0x0

    .line 830
    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sCacheDir:Ljava/io/File;

    .line 831
    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->sInstance:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;

    .line 832
    return-void
.end method

.method public setCacheListener(Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;)V
    .locals 0
    .parameter "listener"

    .prologue
    .line 785
    iput-object p1, p0, Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache;->mCacheListener:Lcom/burstly/lib/component/networkcomponent/burstly/video/VideoCache$IVideoCacheListener;

    .line 786
    return-void
.end method
